#include<bits/stdc++.h>
using namespace std;
int t,n,a[200005],maxx;
vector<int>v1,v2;
int check(){
    int sum=0;
    for(int i=1;i<v1.size();i++){
        sum+=v1[i]*(v1[i]==v1[i-1]);
    }
    for(int i=1;i<v2.size();i++){
        sum+=v2[i]*(v2[i]==v2[i-1]);
    }
    return sum;
}
void dfs(int d){
    if(d==n+1){
        maxx=max(maxx,check());
        return;
    }
    v1.push_back(a[d]);
    dfs(d+1);
    v1.pop_back();
    v2.push_back(a[d]);
    dfs(d+1);
    v2.pop_back();
}
signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        maxx=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        dfs(1);
        printf("%d\n",maxx);
    }
    return 0;
}
